package com.guice.web.guice_webapp_example.quartz.jobs;

import com.guice.web.guice_webapp_example.quartz.Scheduled;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import javax.inject.Singleton;
import java.util.concurrent.atomic.AtomicInteger;

@Singleton
@Scheduled( jobName = "myJob", cronExpression = "0/2 * * * * ?" )
public class Myjob implements Job {
    private AtomicInteger runTimes = new AtomicInteger(0);
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        runTimes.incrementAndGet();
        System.out.println("myJob run time:"+runTimes);
    }
}
